﻿/************************************************************************

   Extended Silverlight Toolkit

   Copyright (C) 2010-2012 Xceed Software Inc.

   This program is provided to you under the terms of the Microsoft Public
   License (Ms-PL) as published at http://extendedsilverlight.codeplex.com/license

   Please purchase a commercial version of this toolkit if you are using
   it in a commercial product. The commercial versions support the project,
   and also include more features for each control, priority support,
   source code, updates, removed watermark, and a proprietary license.

   Visit http://xceed.com and follow @datagrid on Twitter.

  **********************************************************************/

using System;

namespace Xceed.Silverlight.Data
{
  public struct DataQueryParameters
  {
    #region Constructor

    internal DataQueryParameters(
      TakeRequest take,
      SkipRequest skip,
      SortRequest sort,
      FilterRequest filter,
      ItemJumpRequest itemJump,
      JumpRequest jump )
      : this()
    {
      // Make sure two types of jump aren't specified.
      if( ( itemJump != null ) && ( jump != null ) )
        throw new DataInternalException( "An attempt was made to specify both an ItemJumpRequest and a JumpRequest. These requests are mutually exclusive." );

      // Make sure the group jump request is linked with the sort request.
      if( jump != null )
      {
        if( sort == null )
          throw new ArgumentNullException( "sort" );

        // The jump request cannot be more precise than the sort request.
        if( sort.SortDescriptions.Count < jump.Values.Count )
          throw new DataInternalException();
      }

      this.Take = take;
      this.Skip = skip;
      this.Sort = sort;
      this.Filter = filter;
      this.ItemJump = itemJump;
      this.Jump = jump;
    }

    #endregion

    #region Take Property

    public TakeRequest Take
    {
      get;
      private set;
    }

    #endregion

    #region Skip Property

    public SkipRequest Skip
    {
      get;
      private set;
    }

    #endregion

    #region Sort Property

    public SortRequest Sort
    {
      get;
      private set;
    }

    #endregion

    #region Filter Property

    public FilterRequest Filter
    {
      get;
      private set;
    }

    #endregion

    #region ItemJump Property

    public ItemJumpRequest ItemJump
    {
      get;
      private set;
    }

    #endregion

    #region Jump Property

    public JumpRequest Jump
    {
      get;
      private set;
    }

    #endregion
  }
}
